package main

// 队列 包含队头、队尾

type Node struct {
	Value int
	Next  *Node
}

type Queue struct {
	Head *Node
	Tail *Node
}

func (q *Queue) Enqueue(v int) {
	tep := &Node{Value: v}
	if q.Tail == nil {
		q.Head = tep
		q.Tail = tep
	} else {
		q.Tail.Next = tep
		q.Tail = tep
	}
}

func (q *Queue) Dequeue() int {
	if q.Tail == nil {
		return -1
	}
	v := q.Tail.Value
	q.Tail = q.Tail.Next
	return v
}
